import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },

  {
    path: '/player',
    component: Layout,
    redirect: '/player/table',
    name: '球员管理',
    meta: { title: '球员管理', icon: 'user' },
    children: [
      {
        path: 'table',
        name: '球员列表',
        component: () => import('@/views/dbwork/player/list.vue'),
        meta: { title: '球员列表', icon: 'table' }
      },
      {
        path: 'save',
        name: '添加球员',
        component: () => import('@/views/dbwork/player/save.vue'),
        meta: { title: '添加球员', icon: 'tree' }
      },
      {
        path: 'save/:id',
        name: '编辑球员',
        component: () => import('@/views/dbwork/player/save.vue'),
        meta: { title: '编辑球员', noCache: true },
        hidden: true// 隐藏路由
      },
      {
        path: 'data',
        name: '比赛数据',
        component: () => import('@/views/dbwork/player/data.vue'),
        meta: { title: '比赛数据', icon: 'nested' },
      },
      {
        path: 'data/:id',
        name: '比赛数据',
        component: () => import('@/views/dbwork/player/data.vue'),
        meta: { title: '编辑球员', noCache: true },
        hidden: true// 隐藏路由
      },
      {
        path: 'show',
        name: '能力分析',
        component: () => import('@/views/dbwork/player/echarts.vue'),
        meta: { title: '能力分析', icon: 'user' }
      },
      {
        path: 'show/:id',
        name: '能力分析',
        component: () => import('@/views/dbwork/player/echarts.vue'),
        meta: { title: '能力分析', noCache: true },
        hidden: true// 隐藏路由
      }
    ]
  },

  {
    path: '/team',
    component: Layout,
    redirect: '/team/table',
    name: '球队管理',
    meta: { title: '球队管理', icon: 'example' },
    children: [
      {
        path: 'table',
        name: '球队列表',
        component: () => import('@/views/dbwork/team/list.vue'),
        meta: { title: '球队列表', icon: 'tree' }
      },
      {
        path: 'save',
        name: '添加球队',
        component: () => import('@/views/dbwork/team/save.vue'),
        meta: { title: '添加球队', icon: 'form' }
      },
      {
        path: 'detail',
        name: '球队详情',
        component: () => import('@/views/dbwork/team/detail.vue'),
        meta: { title: '球队详情', icon: 'nested' }
      }
    ]
  },
  {
    path: '/data',
    component: Layout,
    redirect: '/data/player',
    name: '数据分析',
    meta: { title: '数据分析', icon: 'form' },
    children: [
      {
        path: 'player',
        name: '球员分析',
        component: () => import('@/views/dbwork/data/playerData.vue'),
        meta: { title: '球员分析', icon: 'user' }
      },
      {
        path: 'team',
        name: '球队分析',
        component: () => import('@/views/dbwork/data/teamData.vue'),
        meta: { title: '球队分析', icon: 'tree' }
      },
      {
        path: 'game',
        name: '赛事分析',
        component: () => import('@/views/dbwork/data/gameData.vue'),
        meta: { title: '赛事分析', icon: 'nested' }
      }
    ]
  },
  {
    path: '/news',
    component: Layout,
    redirect: '/news/table',
    name: '新闻管理',
    meta: { title: '新闻管理', icon: 'table' },
    children: [
      {
        path: 'table',
        name: '新闻列表',
        component: () => import('@/views/dbwork/news/table.vue'),
        meta: { title: '新闻列表', icon: 'form' }
      },
      {
        path: 'edit',
        name: '新闻编辑',
        component: () => import('@/views/dbwork/news/edit.vue'),
        meta: { title: '新闻编辑', icon: 'nested' }
      }
    ]
  },
  {
    path: '/watch',
    component: Layout,
    children: [
      {
        path: 'https://eurocup.cctv.com/2020/?spm=C73465.PhvcG4VlqNFF.EyAwthc54FQC.7',
        meta: { title: '观看球赛Go', icon: 'link' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
